Skip to content

Conversation

@Irev-Dev
Copy link
Contributor

@Irev-Dev Irev-Dev commented Jan 8, 2026

Ostensibly trying to show colours in sketch mode,
image

Resolves #9281

but did a fair bit in rust:

  1. I decided to cache previous freedom_analysis on the rust side, so that I could make them non-nullable for the TS side. Jon you might disagree so let me know
  2. There seemed to be a bug, I don't think conflict variables from Ezpz were being handled correctly (only unsatisfied), and so the values that came back when ever there was a single conflict in the sketch made many of the colours for segments etc wrong. I added freedom_analysis_tests which were failing before I added the fix.

On the TS side I revamp the colors a little to give clear prirotiy of what status wins out for colors, it's the following order now:
draft colour
hover colour
select colour
conflict colour
free colour
fixed colour

Also I added the following logic for deriving the freedom of segment bodies

  • If a single point or more on a segment is conflicted, consider the whole segment conflicted
  • else if a single point or more on a segment is free consider the whole segment free
  • else (implicitly if all points on the segment are fixed) conisder the whole segment fixed

Note

Strengthens freedom/conflict handling end-to-end and aligns UI coloring with solver outputs.

  • Rust: build combined constraints list and compute variables_in_conflicts; replace unsatisfied with variables_in_conflicts in Solved, add Solved::from_ezpz_outcome and helpers to extract variable IDs; propagate conflict info to point freedom; default point freedom to Free when analysis absent
  • Rust frontend: make Point.freedom non-null (Freedom), add point_freedom_cache in FrontendState to preserve previous freedoms when analysis didn’t run; update update_state_after_exec to merge/cache based on freedom_analysis_ran; wire through calls (mock/engine, add/edit/delete) and add targeted tests for freedom analysis conflicts
  • TS: introduce segmentsUtils with deriveSegmentFreedom and getSegmentColor; refactor segment rendering to pass/store freedom, compute hover/selection/draft colors by precedence (draft > hover > select > conflict > free > fixed); compute segment freedom from endpoint points; add comprehensive unit tests for freedom derivation and color selection

Written by Cursor Bugbot for commit 90eb426. This will update automatically on new commits. Configure here.

@Irev-Dev Irev-Dev added the sketch-solve PRs changing sketch-solve functionality only. label Jan 8, 2026
@vercel
Copy link

vercel bot commented Jan 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
modeling-app Ready Ready Preview, Comment Jan 12, 2026 1:59am

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 8, 2026

Merging this PR will not alter performance

✅ 152 untouched benchmarks
⏩ 92 skipped benchmarks1


Comparing kurt-9281 (90eb426) with main (0eb5042)2

Open in CodSpeed

Footnotes

  1. 92 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (948cf3f) during the generation of this report, so 0eb5042 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@Irev-Dev Irev-Dev changed the title [SOLVE WIP]: constraint freedom visualisation [SOLVE]: constraint freedom visualisation Jan 8, 2026
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added these tests failing before I started working on a fix, now they pass.

Comment on lines 83 to 88
(ObjectId(1), Freedom::Fixed), // line1.start
(ObjectId(2), Freedom::Fixed), // line1.end
(ObjectId(4), Freedom::Fixed), // line2.start
(ObjectId(5), Freedom::Free), // line2.end (currently bug shows Conflict)
(ObjectId(7), Freedom::Conflict), // line3.start (currently bug shows Free)
(ObjectId(8), Freedom::Conflict), // line3.end (currently bug shows Free)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The kcl for this is
line1 with both ends fixed
line2 with one end fixed
line3 with two conflicting distance constraint

But before the fix, point_freedoms would come back as fixed, fixed, fixed, conflict, free, free.

@Irev-Dev Irev-Dev marked this pull request as ready for review January 8, 2026 10:53
@Irev-Dev Irev-Dev requested review from a team as code owners January 8, 2026 10:53
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on February 3

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Updated should_force_freedom_analysis to only return true if:
The cache is empty (analysis hasn't run yet)
AND all points are Free (likely default values)
If the cache has values (even if all Free), it means analysis has already run, so we don't force another run. This prevents the repeated retries that led to incorrect results.
What This Fixes
Prevents the infinite loop of retries after each edit
Stops forcing analysis when it has already run
Reduces the chance of hitting the bug where freedom analysis returns incorrect results
The underlying issue (freedom analysis sometimes returning 2 instead of 18 underconstrained) may still occur, but it will happen less often since we're not repeatedly retrying.
Test this and see if segments still turn white. If the issue persists, we may need to investigate why kcl-ezpz freedom analysis returns inconsistent results with the same constraint counts.
@jtran
Copy link
Contributor

jtran commented Jan 9, 2026

Also I added the following logic for deriving the freedom of segment bodies

We use the same logic in Rust to determine the freedom of a point since a point is made up of two vars, one for x and one for y.

@Irev-Dev
Copy link
Contributor Author

Irev-Dev commented Jan 9, 2026

I put a number of things from your feedback into ff0b897 But I've realised there's another bug, It's too late here so will have to wait.

// Derive freedom from segment freedom
let freedomResult: Freedom | null = null
if (objects) {
const segmentObj = objects[idNum]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object lookup uses ID as array index incorrectly

High Severity

The code uses objects[idNum] and objects[id] to look up segment objects, but this incorrectly treats the object ID as an array index. Object IDs are not guaranteed to match their position in the array (e.g., objects might have IDs [1, 2, 4, 5]). The correct approach is objects.find((o) => o?.id === id), which is already used correctly in deriveSegmentFreedom in segmentsUtils.ts. This bug causes freedom values to be looked up for the wrong objects or not found at all.

Additional Locations (1)

Fix in Cursor Fix in Web

Comment on lines +135 to +136
* 4. Conflict color (priority 4) - CONFLICT_COLOR (red)
* 5. Constrained color (priority 5) - TEXT_COLOR (white)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment incorrectly lists the priority order for Fixed and Free colors. The comment states:

  • Priority 5: Constrained color (Fixed) - TEXT_COLOR (white)
  • Priority 6: Unconstrained color (Free) - UNCONSTRAINED_COLOR (brand blue)

But the code implementation (lines 171-183) checks Free before Fixed, making Free priority 5 and Fixed priority 6. This matches the PR description's stated order ("free colour, fixed colour") but contradicts these comments.

Fix:

 * 5. Unconstrained color (priority 5) - UNCONSTRAINED_COLOR (brand blue)
 * 6. Constrained color (priority 6) - TEXT_COLOR (white)

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link
Contributor

@jtran jtran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented a minor couple nits, and clippy is unhappy. But I think it's good otherwise.

@Irev-Dev Irev-Dev merged commit 53a168c into main Jan 12, 2026
81 of 82 checks passed
@Irev-Dev Irev-Dev deleted the kurt-9281 branch January 12, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sketch-solve PRs changing sketch-solve functionality only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Segment freedom visualisation

3 participants